/*
 * @lc app=leetcode.cn id=852 lang=cpp
 *
 * [852] 山脉数组的峰顶索引
 */

// @lc code=start
class Solution
{
public:
  int peakIndexInMountainArray(vector<int>& arr)
  {
    int L = 0, R = arr.size() - 1;
    while (L < R) {
      int M = L + (R - L) / 2;
      if (arr[M] < arr[M + 1])
        L = M + 1;
      else
        R = M;
    }
    return L;
  }
};
// @lc code=end
